from datetime import datetime
from django.conf import settings
from django.db.models import Manager
from django.contrib.sites.managers import CurrentSiteManager

class PodcastManager(CurrentSiteManager):
	
	def public(self):
		"Returns all the ``enabled`` Podcasts, ordered by title."
		return self.get_query_set().filter(enable=True).order_by('title')
		
class EpisodeManager(Manager):
	
	def get_query_set(self):
		return super(EpisodeManager, self).get_query_set().filter(podcast__site=settings.SITE_ID)
		
	def published(self):
		return self.get_query_set().filter(date__lte=datetime.now()).order_by('-date')